﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.Common;
using System.Data.OracleClient;
using System.Data;

namespace FancyIdea.PingShui.Core.DbHelper
{
    public abstract class OracleCommandWrapper : DbCommandWrapper
    {
        public abstract string ConnectionString
        {
            get;
        }

        public OracleCommandWrapper()
        {
        }

        public OracleCommandWrapper(OracleCommandWrapper parent)
            : base(parent)
        {
        }

        #region 实现DbCommnadWrapper接口
        protected override DbConnection CreateConnection()
        {
            return new OracleConnection(ConnectionString);
        }

        protected override DbDataAdapter CreateDataAdapter()
        {
            return new OracleDataAdapter();
        }

        protected override DbCommand CreateCommand()
        {
            return new OracleCommand();
        }

        protected override DbParameter CreateParameter()
        {
            return new OracleParameter();
        }
        #endregion

        #region 添加参数
        public OracleCommandWrapper AddParameter(string name, OracleType type,
            object value)
        {
            OracleParameter parameter = new OracleParameter(name, type);
            parameter.Value = value;
            AddParameter(parameter);
            return this;
        }
        #endregion

        #region 执行命令
        public new OracleDataReader ExecuteReader()
        {
            return base.ExecuteReader() as OracleDataReader;
        }
        #endregion
    }
}
